package com.hjj.controller.advice;

import com.hjj.dto.ResultDTO;
import com.hjj.exception.CRUDException;
import com.hjj.exception.DataVerificationException;
import com.hjj.exception.LoginException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class CRMControllerAdvice {

    @ExceptionHandler(LoginException.class)
    public ResultDTO loginExceptionHandler(LoginException e){
        ResultDTO resultDTO = new ResultDTO();
        resultDTO.setMess(e.getMessage());
        return resultDTO;
    }

    @ExceptionHandler(CRUDException.class)
    public ResultDTO crudExceptionHandler(CRUDException e){
        ResultDTO resultDTO = new ResultDTO();
        resultDTO.setMess(e.getMessage());
        return resultDTO;
    }

    @ExceptionHandler(DataVerificationException.class)
    public ResultDTO dataVerificationExceptionHandler(DataVerificationException e){
        ResultDTO resultDTO = new ResultDTO();
        resultDTO.setMess(e.getMessage());
        return resultDTO;
    }
}
